package thread;

import java.util.Scanner;

/**
 * sleep阻塞
 * 线程提供了一个静态方法:
 *
 */
public class SleepDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
            Scanner scan = new Scanner(System.in);
            int num = scan.nextInt();
            System.out.println(num);
            while (num>1){
                num--;
                System.out.println(num);
                Thread.sleep(1000);
            }
            System.out.println("时间到");
            //让主线程阻塞5秒钟
//            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("程序结束了");
    }
}
